package storage

import (
	"tdy-backend/global"
	"tdy-backend/pkg/storage/oss"
	"tdy-backend/pkg/storage/qiniu"
)

func GetUrl(key string) (fileKey string) {
	storage := global.TYD_CONFIG.GetString("file.storage")
	switch storage {
	case "File":
		domain := global.TYD_CONFIG.GetString("file.config.domain")
		fileKey = domain + key
	case "Qiniu":
		instance := qiniu.NewQiniu()
		fileKey = instance.GetUrl(key)
	case "Oss":
		instance := oss.NewOss()
		fileKey = instance.GetUrl(key)
	default:
		fileKey = key
	}
	return
}
